;;; package --- Summary
;;; code:
(global-set-key (kbd "C-SPC") 'nil)
(global-set-key (kbd "C-2") 'set-mark-command)
(global-set-key (kbd "C-x C-2") 'pop-global-mark)
(setq menu-mar-mode t)
(setq-default tab-width 2)
;;;解决org-mode不能自动换行问题
(setq org-startup-truncated nil)
(global-set-key (kbd "C-!") 'org-time-stamp-inactive)

(set-fontset-font "fontset-default" 'unicode (font-spec :family "Microsoft YaHei"))
(setenv "GIT_PAGER" "/bin/cat")
(setq package-archives '(("gnu"   . "http://elpa.emacs-china.org/gnu/")
                         ("melpa" . "http://elpa.emacs-china.org/melpa/")))

;;;添加multiple-cursors快捷键配置
(global-set-key (kbd "C-c m i") 'mc/mark-all-like-this-dwim)

;;;配置react开发环境
(define-skeleton create-react-component
  "create react commponent"
  nil
  "import React, {Component} from 'react'\n"
  "import PropTypes from 'prop-types'\n\n"
  "class "
  (substring (buffer-name) 0 (- (string-width (buffer-name)) 3))
  " extends Component {\n"
  > "static propTypes = {}\n\n"
  > "constructor(props) {\n"
  > "super(props)\n"
  "  }\n\n"
  > "render() {\n"
  > "return (" _ ")\n"
  "  }\n"
  "}\n\n"
  "export default "
  (substring (buffer-name) 0 (- (string-width (buffer-name)) 3))
  "\n")

(define-skeleton create-react-load-component
  "create react load component"
  nil
  "import Loadable from 'react-loadable'\n"
  "import Loading from './Loading'\n\n"
  "export default Loadable({\n"
  "  loader: () => import(" _ "),\n"
  "  loading: Loading\n"
  "})\n"
  )

(maybe-require-package 'rjsx-mode)
(add-to-list 'auto-mode-alist '(".*\\.js\\'" . rjsx-mode))
(after-load 'rjsx-mode
  (define-abbrev rjsx-mode-abbrev-table "creact" "" 'create-react-component)
  (define-abbrev rjsx-mode-abbrev-table "cload" "" 'create-react-load-component)
  (define-abbrev rjsx-mode-abbrev-table "scu" "shouldComponentUpdate(nextProps, nextState) {\n\n  }")
  (define-abbrev rjsx-mode-abbrev-table "ppsi" "PropTypes.string.isRequired,")
  (define-abbrev rjsx-mode-abbrev-table "ppni" "PropTypes.number.isRequired,")
  (define-abbrev rjsx-mode-abbrev-table "ppai" "PropTypes.array.isRequired,")
  (define-abbrev rjsx-mode-abbrev-table "ppbi" "PropTypes.bool.isRequired,")
  (define-abbrev rjsx-mode-abbrev-table "ppno" "PropTypes.node.isRequired,")
  (define-abbrev rjsx-mode-abbrev-table "ppoi" "PropTypes.object.isRequired,")
  (define-abbrev rjsx-mode-abbrev-table "ppfi" "PropTypes.func.isRequired,")
  (define-abbrev rjsx-mode-abbrev-table "gdsfp" "static getDerivedStateFromProps(props, state) {\n\n  }")
  (define-abbrev rjsx-mode-abbrev-table "cdu" "componentDidUpdate(prevProps, prevState) {\n\n  }")
  (define-abbrev rjsx-mode-abbrev-table "cdm" "componentDidMount() {\n\n  }")
  (define-abbrev rjsx-mode-abbrev-table "ihead" "import PageHeader from 'ant-design-pro/lib/PageHeader'")
  )
(setq skeleton-end-hook nil)
(setq skeleton-further-elements '((abbrev-mode nil)))
(add-hook 'rjsx-mode-hook 'abbrev-mode)
(add-hook 'rjsx-mode-hook 'semantic-mode)

;;company make sense-sensitive
(setq company-dabbrev-downcase nil)

;;yasnippet
(require 'yasnippet)
(yas-global-mode 1)

(provide 'init-local)
;;; init-local.el ends here
